home *** CD-ROM | disk | FTP | other *** search
- //***************************************************************************
- // OATH :: Object-oriented Abstract Type Hierarchy
- //***************************************************************************
- //
- // Copyright (C) 1991, 1990 Texas Instruments Incorporated
- // Permission is granted to any individual or institution
- // to use, copy, modify, and distribute this software,
- // provided that this complete copyright and permission notice
- // is maintained, intact, in all copies and supporting documentation.
- //
- // Texas Instruments Incorporated provides this software "as is"
- // without express or implied warranty.
- //
- //***************************************************************************
- // character (characterA, characterG)
- //
- // History:
- // 06/92 Brian M Kennedy Made TheCharacters array a non-member (porting)
- // 07/91 Brian M Kennedy import, export, typeRegister
- // 06/91 Brian M Kennedy New macros & format; remove printDiagnostic
- // 10/90 Brian M Kennedy Major Rewrite
- // 02/90 Brian M Kennedy Original
- //
- //***************************************************************************
-
- #include "copyright.h"
-
- #include <oath/character.h>
-
- #include <iostream.h>
-
- /////////////////////////////////////////////////////////////////////////////
- // Character Outline Definitions
-
- OUTLINES(character, token)
-
- // Constructors //////////
-
- characterG::
- characterG () // Constructs a new characterG corresponding to the next char
- :tokenG(), Value(Count++)
- {ensure(!AllConstructed, "More than 256 characterLT's constructed!");
- if(!Count)
- AllConstructed = TRUE;
- ValueToCharacters[Value] = this;
- ref();
- }
-
-
- static const characterG
- TheCharacters [OATH_CHAR_CNT];
- // Instantiation of this array creates 256 characterG objects via the
- // default constructor above. The default constructor should only be
- // called by this array instantiation. It cycles through the 256
- // values, instantiating each characterG to the next char value. Each
- // characterG is then placed in the proper position in the array
- // ValueToCharacters so that it can be found by characterA::make.
- // If C++ compilers supported more sophisticated array initialization,
- // then this ugliness would be unnecessary.
-
-
- characterG::
- ~characterG ()
- {}
-
-
- // oathCore Operations //////////
-
- void characterG::
- export (exportP& X) const
- {X.writeType(TypeName);
- X.stream().put(value());
- }
-
- objA characterG::
- import (importP& M)
- {return ValueToCharacters[M.stream().get()];}
-
-
- // Other Operations //////////
-
- ostream&
- operator << (ostream& F, const characterA& C)
- {return F << C.value();}
-
- istream&
- operator >> (istream& F, characterA& C)
- {unsigned char Temp;
- F >> Temp;
- C = characterA::make(Temp);
- return F;
- }
-
-
- // Members //////////
-
- unsigned char
- characterG::Count = 0;
-
- int // TRUE if 256 characters constructed
- characterG::AllConstructed = FALSE;
-
- const char *
- characterG::CharacterNames[OATH_CHAR_CNT] =
-
- {"Nul", "Soh", "Stx", "Etx", "Eot", "Enq", "Ack", "Bel",
- "Bs", "Ht", "Nl", "Vt", "Np", "Cr", "So", "Si",
- "Dle", "Dc1", "Dc2", "Dc3", "Dc4", "Nak", "Syn", "Etb",
- "Can", "Em", "Sub", "Esc", "Fs", "Gs", "Rs", "Us",
-
- "Space", "ExclamationMark", "QuotationMark", "PoundSign",
- "DollarSign", "PercentSign", "Andpersand", "Apostrophe",
- "LeftParenthesis", "RightParenthesis", "Asterisk", "PlusSign",
- "Comma", "Hyphen", "Period", "Slash",
- "Zero", "One", "Two", "Three",
- "Four", "Five", "Six", "Seven",
- "Eight", "Nine", "Colon", "SemiColon",
- "LessThan", "Equal", "GreaterThan", "QuestionMark",
-
- "AtSign", "A", "B", "C", "D", "E", "F", "G",
- "H", "I", "J", "K", "L", "M", "N", "O",
- "P", "Q", "R", "S", "T", "U", "V", "W",
-
- "X", "Y", "Z", "LeftSquareBracket",
- "BackSlash", "RightSquareBracket", "Caret", "UnderScore",
-
- "Accent", "a", "b", "c", "d", "e", "f", "g",
- "h", "i", "j", "k", "l", "m", "n", "o",
- "p", "q", "r", "s", "t", "u", "v", "w",
-
- "x", "y", "z", "LeftBrace",
- "Bar", "RightBrace", "Tilde", "Del",
-
- "XNul", "XSoh", "XStx", "XEtx", "XEot", "XEnq", "XAck", "XBel",
- "XBs", "XHt", "XNl", "XVt", "XNp", "XCr", "XSo", "XSi",
- "XDle", "XDc1", "XDc2", "XDc3", "XDc4", "XNak", "XSyn", "XEtb",
- "XCan", "XEm", "XSub", "XEsc", "XFs", "XGs", "XRs", "XUs",
-
- "XSpace", "XExclamationMark", "XQuotationMark", "XPoundSign",
- "XDollarSign", "XPercentSign", "XAndpersand", "XApostrophe",
- "XLeftParenthesis", "XRightParenthesis", "XAsterisk", "XPlusSign",
- "XComma", "XHyphen", "XPeriod", "XSlash",
- "XZero", "XOne", "XTwo", "XThree",
- "XFour", "XFive", "XSix", "XSeven",
- "XEight", "XNine", "XColon", "XSemiColon",
- "XLessThan", "XEqual", "XGreaterThan", "XQuestionMark",
-
- "XAtSign", "XA", "XB", "XC", "XD", "XE", "XF", "XG",
- "XH", "XI", "XJ", "XK", "XL", "XM", "XN", "XO",
- "XP", "XQ", "XR", "XS", "XT", "XU", "XV", "XW",
-
- "XX", "XY", "XZ", "XLeftSquareBracket",
- "XBackSlash", "XRightSquareBracket", "XCaret", "XUnderScore",
-
- "XAccent", "Xa", "Xb", "Xc", "Xd", "Xe", "Xf", "Xg",
- "Xh", "Xi", "Xj", "Xk", "Xl", "Xm", "Xn", "Xo",
- "Xp", "Xq", "Xr", "Xs", "Xt", "Xu", "Xv", "Xw",
-
- "Xx", "Xy", "Xz", "XLeftBrace",
- "XBar", "XRightBrace", "XTilde", "XDel"
- };
-
- const characterG*
- characterG::ValueToCharacters[OATH_CHAR_CNT];
-
-
- //***************************************************************************
-